
var state = 0;//使用state来避免点击叶节点栏目时，使得click函数被调用。！！！


function loadfunc(obj){
    //var userId = $("#test").val();
    //var userId = document.getElementById("test").getAttribute("value");
    // var userId = $.grep(array,function(value){
    //      return (value == 0 || value == 1) ;
    var data=
        "[                                                                     " +
        "     {name:'求职招聘',value:                                           " +
        "                 [                                                    " +
        "                     {token:'学生求职',url:'mainframe.jsp'},               " +
        "                     {token:'企业招聘',url:'index.jsp'},               " +
        "                     {token:'招聘会',url:'index.jsp'},                 " +
        "                     {token:'发布招聘会',url:'index.jsp'},             " +
        "                     {token:'发布求职信息',url:'../../../InfoPublish/applyMessageInputAction.action'},   " + 
        "                     {token:'发布招聘信息',url:'index.jsp'}            " + 
        "                 ]                                                    " +
        "      },                                                              " +
        "     {name:'管理中心',value:                                           " +
        "                 [                                                    " +
        "                     {token:'注册登录',url:'../../Manage/mainframe.jsp'},               " +
        "                     {token:'回收站',url:'../../Manage/mainframe.jsp'},                 " +
        "                     {token:'数据库备份',url:'../../Manage/mainframe.jsp'},             " +
        "                     {token:'权限分配',url:'../../../manage/ChangeLimit.action'}                " +
        "                 ]                                                    " +
        "      },                                                              " +
        "     {name:'个人中心',value:                                           " +
        "                 [                                                    " +
        "                     {token:'个人信息',url:'../../Manage/mainframe.jsp'},               " +
        "                     {token:'修改密码',url:'../../Manage/mainframe.jsp'},               " +
        "                     {token:'站内信',url:'../../Manage/mainframe.jsp'},                 " +
        "                     {token:'权限认证',url:'../../../manage/ChangeLimit.action'},        " +
        "                     {token:'您的状态',url:'../../Manage/mainframe.jsp'}                " +
        "                 ]                                                    " +
        "      },                                                              " +
        "     {name:'信息查询',value:                                           " +
        "                 [                                                    " +
        "                     {token:'毕业生快速查询',url:'index.jsp'},         " +
        "                     {token:'毕业生高级查询',url:'index.jsp'},               " +
        "                     {token:'普通企业查询',url:'index.jsp'},               " +
        "                     {token:'学生基本简历查询',url:'index.jsp'},                 " +
        "                     {token:'求职查询',url:'index.jsp'},               " +
        "                     {token:'职位查询',url:'index.jsp'}                " +
        "                 ]                                                    " +
        "      },                                                              " +
        "     {name:'统计分析',value:                                           " +
        "                 [                                                    " +
        "                     {token:'应届生就业分析',url:'index.jsp'},         " +
        "                     {token:'整体就业分析',url:'index.jsp'},           " +
        "                     {token:'毕业生学历分析',url:'index.jsp'},         " +
        "                     {token:'毕业生专业类别分析',url:'index.jsp'}       " +

        "                 ]                                                    " +
        "      },                                                              " +
        "     {name:'见习基地',value:                                           " +
        "                 [                                                    " +
        "                     {token:'实习岗位',url:'index.jsp'},               " +
        "                     {token:'实习申请',url:'.../Practicebase/mainframe.jsp'},    " +
        "                     {token:'实习审核',url:'index.jsp'},               " +
        "                     {token:'实习反馈',url:'index.jsp'}                " +
        "                  ]                                                   " +
        "      }                                                               " +
        "]                                                                     " ;
        
    var dataObj=eval("("+data+")");//转换为json对象封装 
    var times = 0;//用来检测是否一个子栏目中未有任何栏目
    var j = 0;
    
        
    $.each(dataObj,function(idx,item){         

    //生成最开始的初始div和标题div
    var $rootdiv = $("<div id='"+item.name+"'></div>").addClass("ini_block");
    var $title = $("<div onclick='clickfunc()'>"
    +item.name+"</div>").css("cursor","hand");
    var $programa = $("<ul></ul>");
    
    $rootdiv.append($title);
    $rootdiv.append($programa);
    $("#navigator").append($rootdiv);
    //alert($rootdiv.html());
    
    //生成子栏目
    for(var i = 0;i<item.value.length;i++)
    {
        //alert("到第一步了");        
        //导航栏生成主程序  
        if(obj[j]==1){
            var $detail = $("<li><a href='"+item.value[i].url+"' target='mainFrame'" +
                    " style='" +
                    "a:hover {color: #FF6600;text-decoration: none'>"
            +item.value[i].token+"</a></li>");          
            $programa.append($detail);                  
            //alert("name:"+item.name+",value:"+item.value[i].token);
            times++;
        }
        j++;
    } 
    
     
    //最后的动画生成
    //使用state来避免点击叶节点栏目时，使得click函数被调用。！！！
    $("#"+item.name+"").click(function(){
    //alert($("#"+item.name+" div").html());
   // alert(state == 1);
    if(state == 1){
    if($(this).hasClass("nowShow")){
         $(this)
         .children("ul").hide(600);
         $(this).removeClass("nowShow");
         //$(this).siblings().addClass("nowShow");
    }
    else{
         $(this).siblings().children("ul").animate({opacity:"0"},500).hide(500);
         $(this)
         .children("ul").animate({opacity:"1"},0)
         .show(600).end();
         $("ul li:last-child").css("padding-bottom","8px "); 
         $(this).addClass("nowShow");
         $(this).siblings().removeClass("nowShow");
    }
    }
    state = 0;
   });
  
    //如果一个栏目都没有，则该子栏目删除。
    if(times==0)
    {
        $("#"+item.name+"").remove();
        //$("#navigator div").remove("div[id=="+item.name+"]");
        //为什么不行？？？？？？？
    }
    times = 0;
    //alert("一步");   
    });
    return this;
    

};

function clickfunc(){
    state = 1;
}

$(function(){
	$(window).bind('load',(function(){
        var height = $(document).height()-75;
    $('#navigator').css('height',height+'px');
    alert($(document).height()-$('#navigator').height());
//  var $trbtm = $('<tr><img src=\"/HuianbysPlatform/images/UIsupport/UIback/navidown.png\" /></tr>');
//    $("#tb tbody").append($trbtm); 
//        return this;
//    })());
//
//
//	
//	
}))});
//$(function(){alert("last");
//    var $trbtm = $('<tr>woshichenchao</tr>');
//    $("#tb tbody").append($trbtm); 
//    //$('#tb').css('height','400px'); 
//       });